<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title><?php echo C('APP_NAME');?>管理后台</title>
    <link rel="stylesheet" href="/Public/layui/css/layui.css">
    <script type="text/javascript" src="/Public/layui/layui.js"></script>
    <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
    
</head>
<body>
<div style="margin: 15px;">
    
    <fieldset class="layui-elem-field">
        <legend>订单管理 - 导出订单</legend>
        <div class="layui-field-box">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span> 订单批次</label>
                    <div class="layui-input-block">
                        <select name="batch" lay-verify="required">
                            <option value="">选择批次</option>
                            <?php if(is_array($batch)): $i = 0; $__LIST__ = $batch;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php echo ($detail['fid'] == $key?'selected':'');?>><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color:red">*</span> 代理</label>
                    <div class="layui-input-block">
                        <select name="agent" lay-verify="required">
                            <option value="">选择代理</option>
                            <option value="999">全部代理</option>
                            <?php if(is_array($agent)): $i = 0; $__LIST__ = $agent;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php echo ($detail['fid'] == $key?'selected':'');?>><?php echo ($vo); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"> 下载连接</label>
                    <div class="layui-input-block">
                        <span id="download"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="admin-form">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>

</div>

    <script>
        layui.use('form', function(){
            var form = layui.form();
            form.on('submit(admin-form)', function(data){
                //console.log(data.field);
                $.ajax({
                    type: "POST",
                    url: '<?php echo U("import");?>',
                    data: data.field,
                    success: function(msg){
                        if( msg.code == 1 ){
                            var str = '<a href="'+  msg.msg +'">下载</a>';
                            $('#download').html(str);
                            //parent.location.reload();
                        }else{
                            parent.layer.msg(msg.msg, {
                                icon: 5,
                                shade: [0.6, '#393D49'],
                                time:1500
                            });
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>
</html>